<?php session_start();
include "constants.php";
$dates=date_create(CUTOFFS);
$cutoffdates=date_format($dates,"m/d/Y");
$displays=SHOWOFFS;
$INITIALS=SPOINT;



$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); 

if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
mysql_select_db(DB_NAME);

$EMAILS=$_POST[emails];
$ACCOUNTID= $_POST[accountid];
$PROFILEID=$_POST[profileid];
$sin=$_POST[sin];
$ulp=$_POST[ulp];
$dta=$_POST[dta];

if($EMAILS!="" && !empty($EMAILS))
{
	$Profiles = "SELECT * FROM Profiles WHERE Email = '$EMAILS'";
	$ProfResu = mysql_query($Profiles,$link);
	$rowProf = mysql_fetch_array($ProfResu);
	$FirstName=$rowProf['FirstName'];
	$LastName=$rowProf['LastName'];
	$Gender=$rowProf['Gender'];
	$BirthDate=$rowProf['BirthDate'];
	$Address=$rowProf['Address'];
	$City=$rowProf['City'];
	$Province=$rowProf['Province'];
	$PostCode=$rowProf['PostCode'];
	$DateIn=$rowProf['DateIn'];
	$PrimaryPhone=$rowProf['PrimaryPhone'];
	$WorkPhone=$rowProf['WorkPhone'];
	$CellPhone=$rowProf['CellPhone'];
	$Email=$rowProf['Email'];
	$Advertisement=$rowProf['Advertisement'];
	$SIN=$rowProf['SIN'];
	$DriverLicense=$rowProf['DriverLicense'];
	$R1Name=$rowProf['R1Name'];
	$R2Name=$rowProf['R2Name'];
	$R1Phone=$rowProf['R1Phone'];
	$R2Phone=$rowProf['R2Phone'];
	$R1Relation=$rowProf['R1Relation'];
	$Refuse=$rowProf['Credit'];
	$RefTimes=$rowProf['CreditNum'];
	$LatestDates=$rowProf['LastDateCredit'];
	$Reasons=$rowProf['Reasons'];	
	$PROFILEID1=$rowProf['ProfileID'];	


	$sql = "SELECT * FROM Applications WHERE ProfileID = '$PROFILEID1' ORDER BY AccountID DESC LIMIT 1";
        $states = mysql_query($sql,$link);        
        $row = mysql_fetch_array($states);
	$PROFILEID=$row['ProfileID'];
        $ACCID=$row['AccountID'];
	$LAmt=$row['BAmount'];
	$Lcst=$row['Costs'];
	$FPday=$row['FirstPayDay'];
	$AppLAmt=$row['ApprovalAmount'];
	$AppLcst=$row['TotalCost'];
	$SchPday=$row['CollectDate'];
	$SPday=$row['SecondPayDay'];
	$Banking=$row['BankName'];		     
	$TranID=$row['TransitID'];
	$DebitID=$row['DebitID'];
	$DebitPWD=$row['DebitPWD'];
	$SQ1=$row['SQ1'];
	$SQ2=$row['SQ2'];
	$SQ3=$row['SQ3'];
	$AS1=$row['AS1'];
	$AS2=$row['AS2'];
	$AS3=$row['AS3'];
	$Employer=$row['Employer'];
	$EPhone=$row['EPhone'];
	$DateHired=$row['DateHired'];
	$JobStatus=$row['JobStatus'];
	$PayType=$row['PayType'];
	$PayFrequency=$row['PayFrequency'];
	$MonthlyIncome=$row['MonthlyIncome'];
	$PayBy=$row['PayBy'];
	$InstitutionID=$row['InstitutionID'];
	$CheckID=$row['CheckID'];
	$DIFF=$row['DD'];

        
} else if($ACCOUNTID!="" && !empty($ACCOUNTID))
{
	$RAID=$ACCOUNTID+$INITIALS;
	$sql = "SELECT * FROM Applications WHERE AccountID = '$RAID'";
        $states = mysql_query($sql,$link);        
        $row = mysql_fetch_array($states);
	$PROFILEID=$row['ProfileID'];
        $ACCID=$row['AccountID'];
	$LAmt=$row['BAmount'];
	$Lcst=$row['Costs'];
	$FPday=$row['FirstPayDay'];
	$AppLAmt=$row['ApprovalAmount'];
	$AppLcst=$row['TotalCost'];
	$SchPday=$row['CollectDate'];
	$SPday=$row['SecondPayDay'];
	$Banking=$row['BankName'];		     
	$TranID=$row['TransitID'];
	$DebitID=$row['DebitID'];
	$DebitPWD=$row['DebitPWD'];
	$SQ1=$row['SQ1'];
	$SQ2=$row['SQ2'];
	$SQ3=$row['SQ3'];
	$SQ4=$row['SQ4'];
	$SQ5=$row['SQ5'];
	$AS1=$row['AS1'];
	$AS2=$row['AS2'];
	$AS3=$row['AS3'];
	$AS4=$row['AS4'];
	$AS5=$row['AS5'];
	$Employer=$row['Employer'];
	$EPhone=$row['EPhone'];
	$DateHired=$row['DateHired'];
	$JobStatus=$row['JobStatus'];
	$PayType=$row['PayType'];
	$PayFrequency=$row['PayFrequency'];
	$MonthlyIncome=$row['MonthlyIncome'];
	$PayBy=$row['PayBy'];
	$InstitutionID=$row['InstitutionID'];
	$CheckID=$row['CheckID'];
	$DIFF=$row['DD'];

	$Profiles = "SELECT * FROM Profiles WHERE ProfileID = '$PROFILEID'";
	$ProfResu = mysql_query($Profiles,$link);
	$rowProf = mysql_fetch_array($ProfResu);
	$FirstName=$rowProf['FirstName'];
	$LastName=$rowProf['LastName'];
	$Gender=$rowProf['Gender'];
	$BirthDate=$rowProf['BirthDate'];
	$Address=$rowProf['Address'];
	$City=$rowProf['City'];
	$Province=$rowProf['Province'];
	$PostCode=$rowProf['PostCode'];
	$DateIn=$rowProf['DateIn'];
	$PrimaryPhone=$rowProf['PrimaryPhone'];
	$WorkPhone=$rowProf['WorkPhone'];
	$CellPhone=$rowProf['CellPhone'];
	$Email=$rowProf['Email'];
	$Advertisement=$rowProf['Advertisement'];
	$SIN=$rowProf['SIN'];
	$DriverLicense=$rowProf['DriverLicense'];
	$R1Name=$rowProf['R1Name'];
	$R2Name=$rowProf['R2Name'];
	$R1Phone=$rowProf['R1Phone'];
	$R2Phone=$rowProf['R2Phone'];
	$R1Relation=$rowProf['R1Relation'];
	$Refuse=$rowProf['Credit'];
	$RefTimes=$rowProf['CreditNum'];
	$LatestDates=$rowProf['LastDateCredit'];
	$Reasons=$rowProf['Reasons'];

        
}
else if($PROFILEID!="" && !empty($PROFILEID))
{
	$Profiles = "SELECT * FROM Profiles WHERE ProfileID = '$PROFILEID'";
	$ProfResu = mysql_query($Profiles,$link);
	$rowProf = mysql_fetch_array($ProfResu);
	$FirstName=$rowProf['FirstName'];
	$LastName=$rowProf['LastName'];
	$Gender=$rowProf['Gender'];
	$BirthDate=$rowProf['BirthDate'];
	$Address=$rowProf['Address'];
	$City=$rowProf['City'];
	$Province=$rowProf['Province'];
	$PostCode=$rowProf['PostCode'];
	$DateIn=$rowProf['DateIn'];
	$PrimaryPhone=$rowProf['PrimaryPhone'];
	$WorkPhone=$rowProf['WorkPhone'];
	$CellPhone=$rowProf['CellPhone'];
	$Email=$rowProf['Email'];
	$Advertisement=$rowProf['Advertisement'];
	$SIN=$rowProf['SIN'];
	$DriverLicense=$rowProf['DriverLicense'];
	$R1Name=$rowProf['R1Name'];
	$R2Name=$rowProf['R2Name'];
	$R1Phone=$rowProf['R1Phone'];
	$R2Phone=$rowProf['R2Phone'];
	$R1Relation=$rowProf['R1Relation'];
	$Refuse=$rowProf['Credit'];
	$RefTimes=$rowProf['CreditNum'];
	$LatestDates=$rowProf['LastDateCredit'];
	$Reasons=$rowProf['Reasons'];      
}
else if($sin!="" && !empty($sin))
{
	$Profiles = "SELECT * FROM Profiles WHERE SIN = '$sin'";
	$ProfResu = mysql_query($Profiles,$link);
	$rowProf = mysql_fetch_array($ProfResu);
	$FirstName=$rowProf['FirstName'];
	$LastName=$rowProf['LastName'];
	$Gender=$rowProf['Gender'];
	$BirthDate=$rowProf['BirthDate'];
	$Address=$rowProf['Address'];
	$City=$rowProf['City'];
	$Province=$rowProf['Province'];
	$PostCode=$rowProf['PostCode'];
	$DateIn=$rowProf['DateIn'];
	$PrimaryPhone=$rowProf['PrimaryPhone'];
	$WorkPhone=$rowProf['WorkPhone'];
	$CellPhone=$rowProf['CellPhone'];
	$Email=$rowProf['Email'];
	$Advertisement=$rowProf['Advertisement'];
	$SIN=$rowProf['SIN'];
	$DriverLicense=$rowProf['DriverLicense'];
	$R1Name=$rowProf['R1Name'];
	$R2Name=$rowProf['R2Name'];
	$R1Phone=$rowProf['R1Phone'];
	$R2Phone=$rowProf['R2Phone'];
	$R1Relation=$rowProf['R1Relation'];
	$Refuse=$rowProf['Credit'];
	$RefTimes=$rowProf['CreditNum'];
	$LatestDates=$rowProf['LastDateCredit'];
	$Reasons=$rowProf['Reasons'];      
}
else if($ulp!="" && !empty($ulp))
{
	$Approval = "UPDATE Applications SET NewApp='2' WHERE AccountID = '$ulp'";
	$ApprovalResu = mysql_query($Approval,$link);
	
}
else if($dta!="" && !empty($dta))
{
	$Approval = "DELETE FROM Applications WHERE AccountID = '$dta'";
	$ApprovalResu = mysql_query($Approval,$link);
	
}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cash2u.ca: Payday loan appliant's Profile Details</title>
<META NAME="Description" CONTENT=Cash2u.ca offers online payday loans and cash advance for Canadians">

</head>
<body>
<div id="maincontainer">

<div id="content">
        <div id="TopSectionWrapper" class="PersonalInfo">
	<!--Starting of Personal Information Section-->
	<div id="TitleInfo" class="TitleInfo"><h2>Details of Applicant Profile</h2></div>
	<form name="Profiles" method="post" action="applysecondpart.php" id="Profiles">
	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
        <td width="140" align="right">First Name:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $FirstName;?>" readonly></td>
        <td width="230" align="right">Last Name:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $LastName;?>"></td>
	</tr>
		
	<tr>
        <td width="140" align="right">Gender:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $Gender;?>" readonly></td>
        <td width="230" align="right">Social Insurance Number:<br/><span style="color:green;font-size:small;">(SIN: 999-999-999)</span></td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $SIN;?>"></td>
	</tr>
				
	<tr>
        <td width="140" align="right">Date of Birth:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $BirthDate;?>" readonly/></td>
        <td width="230" align="right">Address:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $Address;?>"></td>
	</tr>

	<tr>
        <td width="140" align="right">City:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $City;?>"/></td>
        <td width="230" align="right">Province:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $Province;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Post Code:<br/><span style="color:green;font-size:small;">(Post Code:A9A-9A9)</span></td>
        <td width="170"><input type="text" readonly style="width: 150px;" value="<?php echo $PostCode;?>"/></td>
        <td width="230" align="right">When did you move in:<br/><span style="color:green;font-size:small;">(Date: mm/dd/yyyy)</span></td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $DateIn;?>"></td>
	</tr>

	<tr>
        <td width="140" align="right">Primary Phone:<br/><span style="color:green;font-size:small;">(Tel: (999) 999-9999)</span></td>
        <td width="170"><input type="text" readonly value="<?php echo $PrimaryPhone;?>" style="width: 150px;"/></td>
        <td width="230" align="right">Work Phone:<br/><span style="color:green;font-size:small;">(Tel: (999) 999-9999x99999)</span></td>
        <td width="160"><input type="text" readonly value="<?php echo $WorkPhone;?>" style="width: 150px;"></td>
	</tr>

	<tr>
        <td width="140" align="right">Cell Phone <span style="color:green;font-size:small;">(optional):<br/>(Tel: (999) 999-9999)</span></td>
        <td width="170"><input type="text" readonly value="<?php echo $CellPhone;?>" style="width: 150px;"/></td>
        <td width="230" align="right">Driver License/Health Card #:</td>
        <td width="160"><input type="text" readonly value="<?php echo $DriverLicense;?>" style="width:150px;"></td>
	</tr>

	<tr>
        <td width="140" align="right">Reference #1 Name:</td>
        <td width="170"><input type="text" readonly value="<?php echo $R1Name;?>" style="width: 150px;"/></td>
        <td width="230" align="right">Reference #2 Name:<br/><span style="color:green;font-size:small;">(optional)</span></td>
        <td width="160"><input type="text" readonly value="<?php echo $R2Name;?>" style="width: 150px;"></td>
	</tr>
		
	<tr>
        <td width="140" align="right">Reference #1 Phone:<br/><span style="color:green;font-size:small;">(required)</span></td>
        <td width="170"><input type="text" readonly value="<?php echo $R1Phone;?>" style="width: 150px;"/><br/><span style="color:green;font-size:small;">(Tel: (999) 999-9999 x 99999)</span></td>
        <td width="230" align="right">Reference #2 Phone (optional):<br/><span style="color:green;font-size:small;">(Tel: (999) 999-9999x99999)</span></td>
        <td width="160"><input type="text" readonly value="<?php echo $R2Phone;?>" style="width: 150px;" ></td>
	</tr>


	<tr>
        <td width="140" align="right">Relationship :<br/><span style="color:green;font-size:small;">(with Reference  #1)</span></td>
        <td width="170"><input type="text" readonly value="<?php echo $R1Relation;?>" style="width: 150px;"/></td>
        <td width="230" align="right">Where did you know:<br/><span style="color:green;font-size:small;">(www.cash2u.ca)</span></td>
        <td width="160"><input type="text" readonly value="<?php echo $Advertisement;?>" style="width: 150px;"></td>
	</tr>

	<tr>
        <td width="140" align="right">Refused or not:</td>
        <td width="170"><input type="text" readonly value="<?php echo $Refuse;?>" style="width: 150px;"/></td>
        <td width="230" align="right">Refused Times:</td>
        <td width="160"><input type="text" readonly value="<?php echo $RefTimes;?>" style="width: 150px;"></td>
	</tr>

	<tr>
        <td width="140" align="right">Refused Reason:</td>
        <td width="170"><input type="text" readonly style="width: 150px;" value="<?php echo $Reason;?>"/></td>
        <td width="230" align="right">Latest Date when refused:<br/><span style="color:green;font-size:small;">(Date: mm/dd/yyyy)</span></td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $LatestDates;?>"></td>
	</tr>

	</table>	
	
	</form>
<br/>
<br/>
	<div id="TitleInfo" class="TitleInfo"><h2>Applicant's Detail Banking Information</h2></div>
	<form name="eSecondProfiles" method="post">
	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
		<tr>
                <td width="140" align="right">First Name:</td>
                <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $_SESSION['FirstName'];?>"></td>
                <td width="230" align="right">Last Name:</td>
                <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $_SESSION['LastName'];?>"></td>
		</tr>
		
		<tr>
                <td width="140" align="right">Email Address:</td>
                <td width="170"><input type="text" readonly style="width: 150px;" value="<?php echo $_SESSION['Email'];?>"></td>
                <td width="230" align="right">Social Insurance Number:<br/><span style="color:green;font-size:small;">(SIN: 999-999-999)</span></td>
                <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $_SESSION['SIN'];?>"></td>
		</tr>

		<tr>
                <td width="140" align="right">First Pay Date:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
                <td width="170"><input type="text" style="width: 150px;" value="<?php echo $FPday;?>" readonly></td>			
                <td width="230" align="right">Second Pay Date:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
                <td width="160"><input type="text" value="<?php echo $SPday;?>" readonly style="width: 150px;"/></td>
		</tr>

			
		<tr>
                <td width="140" align="right">Bank Name:</td>
                <td width="170"><input type="text" name="ebankname" style="width: 150px;" value="<?php echo $Banking;?>" readonly></td>			
                <td width="230" align="right">Branch Transit Number:</td>
                <td width="160"><input type="text" name="etransitnumber" style="width: 150px;" value="<?php echo $TranID;?>" readonly></td>
		</tr>
		</table>
		
		<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
		<tr>
                <td width="140" align="right">Financial Institution Number:</td>
                <td width="170"><input type="text" name="einstitutionnumber" style="width: 150px;" value="<?php echo $InstitutionID;?>" readonly></td>
                <td width="230" align="right">Checking Account Number:</td>
                <td width="160"><input type="text" name="echeckingnumber" style="width: 150px;" value="<?php echo $CheckID;?>"></td>
		</tr>
	</table>	

	<table cellspacing="4" cellpadding="1" border="0" style="margin: 0 0 0 0;">
	<tr>
        <td width="140" align="right">Debit Card Number:</td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $DebitID;?>"></td>
        <td width="230" align="right">Online banking password:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $DebitPWD;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Security Question #1<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ1;?>"></td>
        <td width="230" align="right">Answer #1:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS1;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Security Question #2<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ2;?>"></td>
        <td width="230" align="right">Answer #2:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS2;?>"></td>
	</tr>

	<tr>
        <td width="140" align="right">Security Question #3<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ3;?>"></td>
        <td width="230" align="right">Answer #3:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS3;?>"></td>
	</tr>

	<tr>
        <td width="140" align="right">Security Question #4<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ4;?>"></td>
        <td width="230" align="right">Answer #4:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS4;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Security Question #5<br/><span style="color:green;font-size:small;">(if have):</span></td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $SQ5;?>"></td>
        <td width="230" align="right">Answer #5:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $AS5;?>"></td>
	</tr>


	<tr>
        <td width="140" align="right">Employer</td>
        <td width="170"><input type="text" style="width: 150px;" readonly value="<?php echo $Employer;?>"></td>
        <td width="230" align="right">Employer Phone:</td>
        <td width="160"><input type="text" style="width: 150px;" readonly value="<?php echo $EPhone;?>"></td>
	</tr>
	
	<tr>
        <td width="140" align="right">Pay Type:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $PayType;?>" readonly></td>			<td width="230" align="right">Pay Frequency:</td>
        <td width="160"><input type="text" value="<?php echo $PayFrequency;?>" readonly style="width: 150px;"/></td>
	</tr>

	<tr>
        <td width="140" align="right">Date Hired:<br/><span style="color:green;font-size:small;">(date: mm/dd/yyyy)</span></td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $DateHired;?>" readonly></td>			<td width="230" align="right">Job Status:</td>
        <td width="160"><input type="text" value="<?php echo $JobStatus;?>" readonly style="width: 150px;"/></td>
	</tr>

	<tr>
        <td width="140" align="right">Total Income:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $MonthlyIncome;?>" readonly></td>			<td width="230" align="right">Pay By:</td>
        <td width="160"><input type="text" value="<?php echo $PayBy;?>" readonly style="width: 150px;"/></td>
	</tr>

	<tr>
        <td width="140" align="right">Loan Amount:</td>
        <td width="170"><input type="text" style="width: 150px;" value="<?php echo $LAmt;?>" readonly></td>			<td width="230" align="right">Loan Cost:</td>
        <td width="160"><input type="text" value="<?php echo $Lcst;?>" readonly style="width: 150px;"/></td>
	</tr>

	</table>
	</form>
	
</div>
</body>
</html>